<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@page import="com.butnet.sqltools.web.Action"%>
<%@page import="com.butnet.sqltools.connection.*"%>
<%@page import="java.sql.Connection" %>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.util.List"%>
<html>
<head>
<title>数据库连接列表</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<style type="text/css">
* {
	font-size: 12px;
}
.header {
	font-weight: bold;
	font-style: italic;
	font-size: 14px;
	background-color: #E0E0E0;
}
table tr td {
	height: 25px;
	padding-left: 7px;
	padding-right: 7px;
}
</style>
<script type="text/javascript">
function onout(dom){
	dom.style.backgroundColor='';
}
function onin(dom){
	dom.style.backgroundColor='#c0c0c0';
}
</script>
</head>
<body>
<a href="Action?method=search">搜索链接配置</a> | <a href="newConfig.jsp">新建配置文件</a>
<table style="border-collapse: collapse;" borderColor="#E0E0E0" cellSpacing="0" cellPadding="0" border="1">
	<tr class="header">
		<td>名称</td>
		<td>配置</td>
		<td>状态</td>
		<td colspan="2">操作</td>
	</tr>
	<%
		DBTools dbs = Action.getDbTools();
		List<String> names = (List<String>) request.getAttribute("names");
		for(int i=0;names!=null&&i<names.size();i++){
			String name = names.get(i);
			Connection con = dbs.get(name);
	%>
	<tr onmouseout="onout(this)" onmouseover="onin(this);">
		<td><%=name %></td>
		<td><%=Action.getDbTools().getConfig(name)==null?"":Action.getDbTools().getConfig(name).toString().replaceAll("\n","<br/>") %></td>
		<td><%=con==null?"未创建":(con.isClosed()?"已断开":"连接") %></td>
		<td><%=con==null||con.isClosed()?"<a href='Action?method=bulid&name="+name+"'>连接</a>":"<a href='Action?method=close&name="+name+"'>断开</a>" %></td>
		<td><%=con==null||con.isClosed()?"<a href='newConfig.jsp?name="+name+"'>配置</a> | <a href='Action?method=delete&name="+name+"'>删除</a>":"<a href='exeSql.jsp?name="+name+"'>执行SQL</a>"%></td>
	</tr>
	<%
		}
	%>
</table>
</body>
</html>
